//前台
this.$http({
                            method: 'POST'
                           ,responseType: 'arraybuffer' // 重要
                           ,url: '/code/ajaxDownZip'
                           ,data:{id:id}
                     }).then((response) => {
                          //console.log(response);
                          let filename=decodeURI(response.headers['filename']);//解码文件名称
                          let blob=new Blob([response.data],{type:'content-type:application/octet-stream'});
                          let url = window.URL.createObjectURL(blob);
                          
                          let a = document.createElement("a");
                          a.href = url;
                          a.download = filename;
                          //a.click();
                          //下面这个写法兼容火狐
                          a.dispatchEvent(new MouseEvent('click', {bubbles: true, cancelable: true, view: window}));
                          window.URL.revokeObjectURL(blob);
                          
                     });
                     
                     
                     
                     
 //后台                    
 @RequestMapping(value = "/ajaxDownZip")
    public void ajaxDownZip(HttpServletResponse response, @RequestBody Map&lt;String, Object&gt; pm) throws IOException {
        // HttpServletResponse response =
        // ((ServletWebRequest)RequestContextHolder.getRequestAttributes()).getResponse();
        String id = (String) pm.get("id");
        String filename = "题目_" + id + ".zip";
        // 把文件名放到head中
        response.setHeader("filename", URLEncoder.encode(filename, "UTF-8"));// 有中文名必须encode，到前台decodeURI
        ServletOutputStream out = response.getOutputStream();
        CodeUtil.zip(out, CodeUtil.questionRootPath(id));
    }
